﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Code.Commen;
using Code.Models;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel;

namespace QianBuo.Lottery.Web.Areas.Manage.Models
{
    [Serializable]
    public class ManagerModel
    {
        public Guid Current { get; set; }
        public IEnumerable<ManagerItem> Manages { get; set; }
    }

    [Serializable]
    public class ManagerItem
    {
        public Guid ID { get; set; }
        public string LoginName { get; set; }
        public int RoleID { get; set; }
        public string RoleName { get; set; }
        public AdminState State { get; set; }
        public DateTime AddTime { get; set; }
        public DateTime? LastLoginTime { get; set; }
        public bool? Inline { get; set; }
    }

    [Serializable, Comparison("ConfirmPwd", "Password", ComparerOperator.Equal, ErrorMessage = "两次输入不一至")]
    public class EditModel
    {
        [Required]
        public Guid ID { get; set; }
        public string LoginName { get; set; }
        [RegularExpression("^.{6,15}$", ErrorMessage = "6-15位")]
        public string Password { get; set; }
        [CustomComparison(ComparerDataType.String, "Password", ComparerOperator.Equal, ErrorMessage = "两次输入不一至")]
        public string ConfirmPwd { get; set; }
        [Required(ErrorMessage = "您的登陆密码"), RegularExpression("^.{6,15}$", ErrorMessage = "6-15位")]
        public string CheckPwd { get; set; }
        /// <summary>
        /// 角色
        /// </summary>
        [Required(ErrorMessage = "*")]
        public int RoleID { get; set; }
        /// <summary>
        /// 状态
        /// </summary>
        [Required(ErrorMessage="*")]
        public AdminState State { get; set; }
        public IEnumerable<SelectListItem> RolesList { get; set; }
    }

    [Serializable, Comparison("ConfirmPwd", "Password", ComparerOperator.Equal,ErrorMessage="两次输入不一至")]
    public class AddManagerModel
    {
        [Required(ErrorMessage="请输入登陆名"), RegularExpression(@"^.{4,15}$", ErrorMessage = "4-15位")]
        public string LoginName { get; set; }
        [Required(ErrorMessage="请输入登陆密码"), RegularExpression("^.{6,15}$", ErrorMessage = "6-15位")]
        public string Password { get; set; }
        [Required(ErrorMessage="确认登陆密码"),CustomComparison(ComparerDataType.String, "Password", ComparerOperator.Equal, ErrorMessage = "两次输入不一至")]
        public string ConfirmPwd { get; set; }
        /// <summary>
        /// 角色
        /// </summary>
        [Required(ErrorMessage="请选择角色")]
        public int RoleID { get; set; }
        /// <summary>
        /// 状态
        /// </summary>
        [Required(ErrorMessage = "*")]
        public AdminState State { get; set; }
        public IEnumerable<SelectListItem> RolesList { get; set; }
    }
}